import { Injectable } from '@angular/core';
import { Router, NavigationEnd,ResolveStart} from '@angular/router';
import { filter } from 'rxjs/operators';
import { PagesService } from 'services/pages.service';
declare var layui: any;
declare var layer: any;
declare var $: any;

@Injectable({
  providedIn: 'root'
})
export class UtilService {

  constructor(public interfaceService: PagesService, private router: Router) {
  }

  /**
   * 新开模块选项卡
   * @param url 
   */
  goTo(url: string) {
    $('button.ant-modal-close.ng-star-inserted').click();
    this.router.navigateByUrl(url);

    /* console.log('新开模块路由->'+url)
    if(url.indexOf('/financial/purchase_requisition') !== -1 || url.indexOf('/goods/cycle/product_cycle') !== -1 ||
     url.indexOf('/goods/cycle/product_cycle_manage') !== -1){
      // window.location.reload();
    } */
  }

  /**
   * 重载页面表格元素宽度
   */
  /* privIds=this.interfaceService.GetQueryString("privId")
  resetTableSize() {
    this.router.events.pipe(
      filter(event => event instanceof NavigationEnd))
      .subscribe((event) => {
        const isState=this.utilService.isState[this.interfaceService.GetQueryString("privId")]
        console.log('切换选项卡模块',localStorage.getItem('tabTitle'),localStorage.getItem('isRoute'),isState,event)
        this.privIds=this.interfaceService.GetQueryString("privId")
        $('.'+this.privIds+' button.tabBlock').click();
        $(window).resize();
        $('.layui-table-tips .layui-layer-content i.layui-icon-close').click();
        if(localStorage.getItem('isRoute')==='1'){//选项卡已打开状态

        }
      });
  } */
  


}
